package cc.ucanuup.service.base.dao;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cc.ucanuup.service.base.entity.UpRole;

/**
 * Description: TODO[描述该类概要功能介绍]
 *
 * @author guwenbin
 * @date 2018年2月3日
 * @version 1.0
 */
public interface UpRoleJPA extends JpaRepository<UpRole , Serializable>,JpaSpecificationExecutor<UpRole>{

	/**
	 * @Method: com.bozhon.srm.service.base.datamanager.UpRoleJPA.findRoleListByUserId
	 * @Description: 通过SrmSupplier 主键 --->>>关联表查询UpRole信息
	 * @author: WenBin
	 * @date: 2018年2月5日
	 * @version: 1.0
	 * @param userId
	 * @return
	 * List<UpRole>
	 * @update [日期YYYY-MM-DD] [更改人姓名][变更描述]
	 */
	@Query(value="select t.* from TBUP_ROLE t "
			+ " left join RELATION_USER_ROLE rur on rur.ROLE_ID = t.ID "
			+ " where rur.USER_ID = :userId",nativeQuery=true)
	List<UpRole> findRoleListByUserId(@Param("userId") String userId);

	@Query("select t from UpRole t where t.powerType = :powerType")
	List<UpRole> findDefaultRoleWithType(@Param("powerType") String powerType);

}
